-------------------------------------------------------------------------------
Sample Name: Tetris

Description: The title speaks for itself. This one-form sample uses control 
             arrays to create different shapes and Windows API calls to play 
             sounds. 

Download URL: http://www.it-lang-vb.net/download.asp?file=http://www.it-lang-vb.net/Archivio/Sorgenti/Tetris.zip&ID=236
-------------------------------------------------------------------------------

IMPORTANT NOTE
The first step to ensure that you can migrate the VB6 project to VB.NET is 
loading the original project in the Visual Basic 6 IDE, run it to ensure that 
it works fine, that all the required type libraries are installed, and that all 
file paths are correct. 
Regardless of whether you edited the source code in any way, you should save 
the VB6 project: this save operation ensures that the .vbp file includes  
the correct path and version of referenced type libraries. 
After saving the project, it's usually a good idea to compile the VB6 project
to an executable, to detect any VB6 compilation errors that would appear under 
VB.NET as well. 
(If you don't recompile the project VB Migration Partner will display a warning 
when you later load the project.)


First, you need one AddDataFile pragma to ensure that all *.wav files are included
in the converted VB.NET solution. Second, you need an ArrayBounds pragma to 
solve a problem with two arrays whose lower index is nonzero. You can add both
pragmas in the frmTetris form, as show here:


'##AddDataFile WAV\*.*

Option Explicit

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_ASYNC = &H1
Private Const SND_NOSTOP = &H2000 '&H10
Private Const SND_NOWAIT = &H2000

Const SND_RUOTA As Integer = 1
Const SND_SPOSTA As Integer = 2
Const SND_DROP As Integer = 3
Const SND_TETRIS As Integer = 4
Const SND_FINE As Integer = 5
Const SND_RIGA As Integer = 6

Private Blocco As tyBlocco

Const CDx As Integer = 1
Const CSx As Integer = -1
Const CDw As Integer = 2
Const CRd As Integer = 3
Const CRs As Integer = 4

Const iRow As Integer = 15
Const iCol As Integer = 9

Public iPxlLato As Integer

'##iGriglia.ArrayBounds ForceZero
Private iGriglia(1 To iCol, 1 To iRow) As Integer

Const CVuoto   As Integer = 0
Const CVerde   As Integer = 1
Const CBlu     As Integer = 2
Const CRosso   As Integer = 3
Const CRosa    As Integer = 4
Const CGiallo  As Integer = 5
Const CArancio As Integer = 6
Const CViola   As Integer = 7
Const CGrigio  As Integer = 10

Const CBLs   As Integer = 1
Const CBLd   As Integer = 2
Const CBSs   As Integer = 3
Const CBSd   As Integer = 4
Const CBT    As Integer = 5
Const CBI    As Integer = 6
Const CBQ    As Integer = 7

Private i As Integer
Private j As Integer

Private Type tyQuadro
    X As Integer
    Y As Integer
  End Type

Private Type tyBlocco
    Q1 As tyQuadro
    Q2 As tyQuadro
    Q3 As tyQuadro
    Q4 As tyQuadro
    qdRot As tyQuadro ' punto di rotazione
    iTipo As Integer  ' iTipo di blocco
    iClr  As Integer  ' colore
  End Type

Const CVelBase    As Integer = 1200
Const CVelBoost   As Integer = 30
Public iVelocita As Integer
   
Public iPuntiBoost As Integer

Public iLivello As Integer

Const CNBlocchi As Integer = 7

'##ArrayBounds ForceZero
Private iBlocchi(1 To CNBlocchi) As tyBlocco

Const sMsgPausa    As String = "Premi F3 per continuare"
Const sMsgFine     As String = "GAME OVER"
Const sMsgInizio   As String = "Premi F2 per iniziare"
Const sMsgs As String = " "

Private bPausa As Boolean





VB6 and VB.NET differ in how they manage form borders. A form whose 
BorderStyle property is set to 0-None but whose Caption property is set 
to a nonempty string appears in VB6 as a form with a border and a caption.
The same form appears as a caption-less form under VB.NET.

You can work around thi issue by adding a pragma that manually sets the 
BorderStyle property of the converted form. Add this line at the top 
of frmTetris form:

'##WriteProperty BorderStyle, 1

Now you migration is complete. Have fun with the Tetris game! 




VB Migration Partner typically delivers many warnings that are related to 
code analysis as well as suggestions about how you can improve the original 
VB6 code before converting it to VB.NET. 
You can suppress these warnings by adding the following project-level pragmas 
at the top of any of the file that make up the project:

'##project:DisableMessage 0501
